package com.gyf.mybatis.sqlsession;

import com.gyf.mybatis.config.XMLConfigBuilder;
import com.gyf.mybatis.pojo.Configuration;

import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionBuilder {

    public SqlSessionFactory build(InputStream in) throws DocumentException, PropertyVetoException {

        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();

        Configuration configuration = xmlConfigBuilder.parseConfig(in);

        SqlSessionFactory factory = new DefaultSqlSessionFactory(configuration);

        return factory;
    }
}
